package com.xintai.approval.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xintai.common.annotation.Log;
import com.xintai.common.core.controller.BaseController;
import com.xintai.common.core.domain.AjaxResult;
import com.xintai.common.enums.BusinessType;
import com.xintai.approval.domain.FlowBasicinfo;
import com.xintai.approval.service.IFlowBasicinfoService;
import com.xintai.common.utils.poi.ExcelUtil;
import com.xintai.common.core.page.TableDataInfo;

/**
 * 定义流程的基本信息Controller
 *
 * @author xintai
 * @date 2021-02-01
 */
@RestController
@RequestMapping("/approval/basicinfo")
public class FlowBasicinfoController extends BaseController
{
    @Autowired
    private IFlowBasicinfoService flowBasicinfoService;

    /**
     * 查询定义流程的基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('approval:basicinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(FlowBasicinfo flowBasicinfo)
    {
        startPage();
        List<FlowBasicinfo> list = flowBasicinfoService.selectFlowBasicinfoList(flowBasicinfo);
        return getDataTable(list);
    }

    /**
     * 导出定义流程的基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('approval:basicinfo:export')")
    @Log(title = "定义流程的基本信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FlowBasicinfo flowBasicinfo)
    {
        List<FlowBasicinfo> list = flowBasicinfoService.selectFlowBasicinfoList(flowBasicinfo);
        ExcelUtil<FlowBasicinfo> util = new ExcelUtil<FlowBasicinfo>(FlowBasicinfo.class);
        return util.exportExcel(list, "basicinfo");
    }

    /**
     * 获取定义流程的基本信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('approval:basicinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(flowBasicinfoService.selectFlowBasicinfoById(id));
    }

    /**
     * 新增定义流程的基本信息
     */
    @PreAuthorize("@ss.hasPermi('approval:basicinfo:add')")
    @Log(title = "定义流程的基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlowBasicinfo flowBasicinfo)
    {
        return toAjax(flowBasicinfoService.insertFlowBasicinfo(flowBasicinfo));
    }

    /**
     * 修改定义流程的基本信息
     */
    @PreAuthorize("@ss.hasPermi('approval:basicinfo:edit')")
    @Log(title = "定义流程的基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlowBasicinfo flowBasicinfo)
    {
        return toAjax(flowBasicinfoService.updateFlowBasicinfo(flowBasicinfo));
    }

    /**
     * 删除定义流程的基本信息
     */
    @PreAuthorize("@ss.hasPermi('approval:basicinfo:remove')")
    @Log(title = "定义流程的基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(flowBasicinfoService.deleteFlowBasicinfoByIds(ids));
    }
}
